home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- from datetime import datetime
- from time import strptime
- from email import Utils
-
- class LPTime(datetime):
-
- def convert_rfc2822_time(time_str):
- """ converts a time-string used in /+text into a time-tuple
- time_str: like 'Tue, 27 Nov 2007 11:15:12 -0000'
- returns: time tuple
- """
- return Utils.parsedate(time_str)[0:6]
-
- convert_rfc2822_time = staticmethod(convert_rfc2822_time)
-
- def convert_text_time(time_str):
- """ converts a time-string used in /+text into a time-tuple
- time_str: like 'Tue, 27 Nov 2007 11:15:12 -0000'
- returns: time tuple
- """
- return strptime(time_str, '%a, %d %b %Y %H:%M:%S -0000')[0:6]
-
- convert_text_time = staticmethod(convert_text_time)
-
- def convert_html_time(time_str):
- """ converts a time-string used in html-page into a time-tuple
- time_str: like '2007-11-27 11:15:12 UTC'
- returns: time tuple
- """
- return strptime(time_str, '%Y-%m-%d %H:%M:%S %Z')[0:6]
-
- convert_html_time = staticmethod(convert_html_time)
-
- def convert_activity_time(time_str):
- """ converts a time-string used in activity-log-html-page into a time-tuple
- time_str: like '28 Nov 07 20:10'
- returns: time tuple
- """
- return strptime(time_str, '%d %b %y %H:%M')[0:6]
-
- convert_activity_time = staticmethod(convert_activity_time)
-
- def convert_lastcomment_time(time_str):
- """ converts a time-string used in lastzcomment-function into a time-tuple
- time_str: like '2007-12-24'
- returns: time tuple
- """
- return strptime(time_str, '%Y-%m-%d')[0:3]
-
- convert_lastcomment_time = staticmethod(convert_lastcomment_time)
-
- def __new__(cls, time_str):
- t = None
- conv_functions = (LPTime.convert_rfc2822_time, LPTime.convert_text_time, LPTime.convert_html_time, LPTime.convert_activity_time, LPTime.convert_lastcomment_time)
- for i in conv_functions:
-
- try:
- t = i(time_str)
- if t[0] < 1900:
- continue
-
- continue
- except (ValueError, TypeError):
- continue
- continue
-
-
- else:
- x = time_str.split()
- if x[-1].isalpha():
-
- try:
- x[-1] = 'UTC'
- t = LPTime.convert_html_time(' '.join(x))
- if t[0] < 1900:
- t = None
- except (ValueError, TypeError):
- None<EXCEPTION MATCH>(ValueError, TypeError)
- None<EXCEPTION MATCH>(ValueError, TypeError)
- except:
- None<EXCEPTION MATCH>(ValueError, TypeError)<EXCEPTION MATCH>(ValueError, TypeError)
-
-
- if not t:
- raise ValueError, 'Unknown date format (%s)' % time_str
- t
- obj = super(LPTime, cls).__new__(LPTime, *t)
- if obj.year < 1900:
- if obj.year < 50:
- obj = obj.replace(year = obj.year + 2000)
- else:
- obj = obj.replace(year = obj.year + 1900)
-
- return obj
-
-
- def __str__(self):
- return self.strftime('%Y-%m-%d %H:%M:%S UTC')
-
-
-